SlideShare a Scribd company logo
我的 Julia 軟體架構演進之旅
Yueh-Hua Tu Ph.D.
ML Engineer@Taiwan AI Labs
Saturday 29th July, 2023
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 1 / 28
Projects
Open source projects
FluxML/GeometricFlux.jl
yuehhua/GraphSignals.jl
yuehhua/CDGRNs.jl
JuliaSingleCellOmics/SnowyOwl.jl
Current work
Federated learning system architecture
Bioinformatics analysis tool development
(e.g. GWAS, linkage disequilibrium and
statistics)
Program optimization for execution
performance
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 2 / 28
Outline
1. Prototyping-Development Iteration
2. TDD and Test Coverage
3. Evolutionary Design
4. Principles of Software Engineering
5. Development Mindset
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 3 / 28
Developing from scratch
If we want a project for statistical analysis, where could we start?
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 4 / 28
Prototyping linear regression
Inference
y = Xβ
1 julia> predict(X, β)=X∗β
Fitting
β = (XT
X)−1
XT
y
1 julia> fit(X, y) = inv(X'*X) * X'*y
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 5 / 28
Prototyping-Development Iteration
Prototyping-Development Iteration
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 6 / 28
Prototyping-Development Iteration
Prototyping-Development Iteration (PDI)
Prototyping first then develop for flexibility and performance!
For prototyping and researching
Figure: Scripts
⇒
For development
Figure: Codebase
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 7 / 28
Prototyping-Development Iteration
Prototyping
Figure: Scripts
Implement a simple and standalone feature in a script
to ensure correctness.
1 julia> predict(X, β)=X∗β
2
3 julia> fit(X, y) = inv(X'*X) * X'*y
And try to wrap these features into functions.
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 8 / 28
Prototyping-Development Iteration
Development
Figure: Codebase
Puts functions or components into your codebase and design for
reusablility and flexibility.
1 struct LinearRegressionModel
2 β
3 end
4
5 coefs(m::LinearRegressionModel) = m.β
6
7 predict(m::LinearRegressionModel, X) = X*coefs(m)
8
9 fit(::Type{LinearRegressionModel}, X, y) =
LinearRegressionModel(inv(X'*X) * X'*y)
,
→
After putting components into codebase, ensure your scripts still work for you. Don't put to
much specifics into codebase (e.g. data, configs).
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 9 / 28
TDD and Test Coverage
TDD and Test Coverage
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 10 / 28
TDD and Test Coverage
Test-Driven Development (TDD)
Actually, PDI is a kind of TDD process.
We still need to add some test cases and ensure tests are passed.
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 11 / 28
TDD and Test Coverage
TDD in Julia
TDD is very simple in Julia.
test/runtests.jl
1 @testset "MyProject.jl" begin
2 @test coefs(model) == β
3 ...
4 end
1 (@v1.9) pkg> test
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 12 / 28
TDD and Test Coverage
Develop for flexibility
src/stats.jl
1 cov(X, Y) = innerprod(X, Y)
src/linalg.jl
1 innerprod(x, y) = x'*y
src/regression.jl
fit(::Type{LinearRegressionModel}, X, y) = LinearRegressionModel(inv(innerprod(X, X)) *
innerprod(X, y))
,
→
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 13 / 28
TDD and Test Coverage
Develop for performance
src/linalg.jl
function innerprod(X::AbstractMatrix, y::AbstractVector)
# acceleration techniques: SIMD, GPU...
end
function innerprod(X::AbstractMatrix, Y::AbstractMatrix)
# acceleration techniques: SIMD, GPU...
end
Specification for optimization and keep consistent interfaces.
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 14 / 28
TDD and Test Coverage
Test coverage
Keep high test coverage as possible to ensure your codebase provides desired features.
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 15 / 28
Evolutionary Design
Evolutionary Design
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 16 / 28
Evolutionary Design
Adding new features
If we want to add new approach to solve a linear system, how can we do?
Ax = b
1 using LinearSolve
2
3 A = rand(4, 4)
4 b = rand(4)
5 prob = LinearProblem(A, b)
6 sol = solve(prob)
Adding new features could be prototyped by
Adding types
Extending existing functions
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 17 / 28
Evolutionary Design
Adding types
Original
struct RegularSolver end
solve(m::RegularSolver, A, b) =
solve(LinearProblem(A, b))
,
→
⇒
Adding CholeskySolver
1 abstract type LinearSolver end
2
3 struct RegularSolver <: LinearSolver end
4 struct CholeskySolver <: LinearSolver end
5
6 solve(m::RegularSolver, A, b) =
solve(LinearProblem(A, b))
,
→
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 18 / 28
Evolutionary Design
Extending functions/methods
Original
abstract type LinearSolver end
struct RegularSolver <:
LinearSolver end
,
→
struct CholeskySolver <:
LinearSolver end
,
→
solve(m::RegularSolver, A, b) =
solve(LinearProblem(A, b))
,
→
⇒
Extending solve to CholeskySolver.
1 abstract type LinearSolver end
2
3 struct RegularSolver <: LinearSolver end
4 struct CholeskySolver <: LinearSolver end
5
6 solve(m::RegularSolver, A, b) =
solve(LinearProblem(A, b))
,
→
7 solve(m::CholeskySolver, A, b) = #
Cholesky decomposition...
,
→
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 19 / 28
Principles of Software Engineering
Principles of Software Engineering
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 20 / 28
Principles of Software Engineering
Single Responsibility Principle
A class or function should be responsible to only one actor.
LinearModel: represent a linear model
coefs: returns model coefficients
fit: fitting model
LinearSolver: approach to solve a linear system
solve: determines how to solve a linear system
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 21 / 28
Principles of Software Engineering
Open-Closed Principle
A module will be said to be open for extension and be said to be closed for modification.
struct LinearRegressionModel
β
end
coefs(m::LinearRegressionModel) =
m.β
⇒
1 abstract type LinearModel end
2
3 struct LinearRegressionModel <:
LinearModel
,
→
4 β
5 end
6
7 struct LogisticRegressionModel <:
LinearModel
,
→
8 β
9 end
10
11 coefs(m::LinearRegressionModel) = m.β
12 coefs(m::LogisticRegressionModel) = m.β
Benefitial from Julia's features of type and method separation, it's easy to add new types or
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 22 / 28
Principles of Software Engineering
Liskov Substitution Principle
Derived class can be able to replace its base class.
abstract type LinearModel end
struct LinearRegressionModel <: LinearModel
β
end
struct LogisticRegressionModel <: LinearModel
β
end
Since Julia's subtyping system doesn't allow composite types as super types, Julia always run
composite types in practice.
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 23 / 28
Principles of Software Engineering
Interface Segregation Principle
No code should be forced to depend on methods it does not use.
1 julia> model = fit(LinearRegressionModel,
X, y)
,
→
2
3 julia> coefs(model)
4
5 julia> model =
fit(LogisticRegressionModel, X, y)
,
→
6
7 julia> coefs(model)
User just need to know interfaces.
1 module MyPackage
2 abstract type LinearModel end
3 struct LinearRegressionModel <:
LinearModel
,
→
4 β
5 end
6 struct LogisticRegressionModel <:
LinearModel
,
→
7 β
8 end
9 coefs(m::LinearRegressionModel) = m.β
10 coefs(m::LogisticRegressionModel) =
m.β
11 end
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 24 / 28
Principles of Software Engineering
Dependency Inversion Principle
Dependency injection
1 abstract type LinearSolver end
2
3 struct RegularSolver <: LinearSolver end
4 struct CholeskySolver <: LinearSolver end
5 struct QRSolver <: LinearSolver end
1 abstract type LinearModel end
2
3 struct LinearRegressionModel <:
LinearModel end
,
→
4 struct LogisticRegressionModel <:
LinearModel end
,
→
5
6 fit(::Type{LinearRegressionModel}, X, y;
algo=CholeskySolver())
,
→
7 fit(::Type{LogisticRegressionModel}, X, y;
algo=CholeskySolver())
,
→
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 25 / 28
Development Mindset
Development Mindset
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 26 / 28
Development Mindset
Issues and Pull Requests
貢獻者
遇到善於給建議(機車)的人
如何主持跟維護專案
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 27 / 28
Development Mindset
Thank you for attention
Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th
July, 2023 28 / 28

More Related Content

Similar to [COSCUP 2023] 我的Julia軟體架構演進之旅

9781111530532 ppt ch08
9781111530532 ppt ch089781111530532 ppt ch08
9781111530532 ppt ch08Terry Yoast
 
Feature Bits at LSSC10
Feature  Bits at LSSC10Feature  Bits at LSSC10
Feature Bits at LSSC10
Erik Sowa
 
Generation of Testcases from UML Sequence Diagram and Detecting Deadlocks usi...
Generation of Testcases from UML Sequence Diagram and Detecting Deadlocks usi...Generation of Testcases from UML Sequence Diagram and Detecting Deadlocks usi...
Generation of Testcases from UML Sequence Diagram and Detecting Deadlocks usi...
KIIT
 
J unit presentation
J unit presentationJ unit presentation
J unit presentationPriya Sharma
 
JUnit Presentation
JUnit PresentationJUnit Presentation
JUnit Presentation
priya_trivedi
 
Ujjwalreverseengineeringppptfinal
UjjwalreverseengineeringppptfinalUjjwalreverseengineeringppptfinal
Ujjwalreverseengineeringppptfinalujjwalchauhan87
 
Benchmarking the Parallel 1D Heat Equation Solver in Chapel, Charm++, C++, HP...
Benchmarking the Parallel 1D Heat Equation Solver in Chapel, Charm++, C++, HP...Benchmarking the Parallel 1D Heat Equation Solver in Chapel, Charm++, C++, HP...
Benchmarking the Parallel 1D Heat Equation Solver in Chapel, Charm++, C++, HP...
Patrick Diehl
 
Poster on Automated Refactoring of Legacy Java Software to Default Methods
Poster on Automated Refactoring of Legacy Java Software to Default MethodsPoster on Automated Refactoring of Legacy Java Software to Default Methods
Poster on Automated Refactoring of Legacy Java Software to Default Methods
Raffi Khatchadourian
 
OOAD-Unit1.ppt
OOAD-Unit1.pptOOAD-Unit1.ppt
OOAD-Unit1.ppt
rituah
 
Julia: A modern language for software 2.0
Julia: A modern language for software 2.0Julia: A modern language for software 2.0
Julia: A modern language for software 2.0
Viral Shah
 
Future Programming Language
Future Programming LanguageFuture Programming Language
Future Programming LanguageYLTO
 
Ptidej Architecture, Design, and Implementation in Action v2.1
Ptidej Architecture, Design, and Implementation in Action v2.1Ptidej Architecture, Design, and Implementation in Action v2.1
Ptidej Architecture, Design, and Implementation in Action v2.1
Yann-Gaël Guéhéneuc
 
opps.pptx
opps.pptxopps.pptx
opps.pptx
SurajDasgupta2
 
IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...
IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...
IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...
IRJET Journal
 
Value objects in JS - an ES7 work in progress
Value objects in JS - an ES7 work in progressValue objects in JS - an ES7 work in progress
Value objects in JS - an ES7 work in progress
Brendan Eich
 
Unit Testing Frameworks: A comparative study
Unit Testing Frameworks: A comparative studyUnit Testing Frameworks: A comparative study
Unit Testing Frameworks: A comparative study
IRJET Journal
 
Devry CIS 355A Full Course Latest
Devry CIS 355A Full Course LatestDevry CIS 355A Full Course Latest
Devry CIS 355A Full Course Latest
Atifkhilji
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
Sergii Stets
 

Similar to [COSCUP 2023] 我的Julia軟體架構演進之旅 (20)

9781111530532 ppt ch08
9781111530532 ppt ch089781111530532 ppt ch08
9781111530532 ppt ch08
 
Feature Bits at LSSC10
Feature  Bits at LSSC10Feature  Bits at LSSC10
Feature Bits at LSSC10
 
Generation of Testcases from UML Sequence Diagram and Detecting Deadlocks usi...
Generation of Testcases from UML Sequence Diagram and Detecting Deadlocks usi...Generation of Testcases from UML Sequence Diagram and Detecting Deadlocks usi...
Generation of Testcases from UML Sequence Diagram and Detecting Deadlocks usi...
 
J unit presentation
J unit presentationJ unit presentation
J unit presentation
 
JUnit Presentation
JUnit PresentationJUnit Presentation
JUnit Presentation
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Ujjwalreverseengineeringppptfinal
UjjwalreverseengineeringppptfinalUjjwalreverseengineeringppptfinal
Ujjwalreverseengineeringppptfinal
 
Benchmarking the Parallel 1D Heat Equation Solver in Chapel, Charm++, C++, HP...
Benchmarking the Parallel 1D Heat Equation Solver in Chapel, Charm++, C++, HP...Benchmarking the Parallel 1D Heat Equation Solver in Chapel, Charm++, C++, HP...
Benchmarking the Parallel 1D Heat Equation Solver in Chapel, Charm++, C++, HP...
 
Poster on Automated Refactoring of Legacy Java Software to Default Methods
Poster on Automated Refactoring of Legacy Java Software to Default MethodsPoster on Automated Refactoring of Legacy Java Software to Default Methods
Poster on Automated Refactoring of Legacy Java Software to Default Methods
 
OOAD-Unit1.ppt
OOAD-Unit1.pptOOAD-Unit1.ppt
OOAD-Unit1.ppt
 
Julia: A modern language for software 2.0
Julia: A modern language for software 2.0Julia: A modern language for software 2.0
Julia: A modern language for software 2.0
 
Future Programming Language
Future Programming LanguageFuture Programming Language
Future Programming Language
 
Ptidej Architecture, Design, and Implementation in Action v2.1
Ptidej Architecture, Design, and Implementation in Action v2.1Ptidej Architecture, Design, and Implementation in Action v2.1
Ptidej Architecture, Design, and Implementation in Action v2.1
 
Oops ppt
Oops pptOops ppt
Oops ppt
 
opps.pptx
opps.pptxopps.pptx
opps.pptx
 
IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...
IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...
IRJET- Unabridged Review of Supervised Machine Learning Regression and Classi...
 
Value objects in JS - an ES7 work in progress
Value objects in JS - an ES7 work in progressValue objects in JS - an ES7 work in progress
Value objects in JS - an ES7 work in progress
 
Unit Testing Frameworks: A comparative study
Unit Testing Frameworks: A comparative studyUnit Testing Frameworks: A comparative study
Unit Testing Frameworks: A comparative study
 
Devry CIS 355A Full Course Latest
Devry CIS 355A Full Course LatestDevry CIS 355A Full Course Latest
Devry CIS 355A Full Course Latest
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 

More from 岳華 杜

Julia: The language for future
Julia: The language for futureJulia: The language for future
Julia: The language for future
岳華 杜
 
The Language for future-julia
The Language for future-juliaThe Language for future-julia
The Language for future-julia
岳華 杜
 
20190907 Julia the language for future
20190907 Julia the language for future20190907 Julia the language for future
20190907 Julia the language for future
岳華 杜
 
Metaprogramming in julia
Metaprogramming in juliaMetaprogramming in julia
Metaprogramming in julia
岳華 杜
 
Introduction to julia
Introduction to juliaIntroduction to julia
Introduction to julia
岳華 杜
 
自然語言處理概覽
自然語言處理概覽自然語言處理概覽
自然語言處理概覽
岳華 杜
 
Introduction to machine learning
Introduction to machine learningIntroduction to machine learning
Introduction to machine learning
岳華 杜
 
Semantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
Semantic Segmentation - Fully Convolutional Networks for Semantic SegmentationSemantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
Semantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
岳華 杜
 
Batch normalization 與他愉快的小伙伴
Batch normalization 與他愉快的小伙伴Batch normalization 與他愉快的小伙伴
Batch normalization 與他愉快的小伙伴
岳華 杜
 
從 VAE 走向深度學習新理論
從 VAE 走向深度學習新理論從 VAE 走向深度學習新理論
從 VAE 走向深度學習新理論
岳華 杜
 
COSCUP: Foreign Function Call in Julia
COSCUP: Foreign Function Call in JuliaCOSCUP: Foreign Function Call in Julia
COSCUP: Foreign Function Call in Julia
岳華 杜
 
COSCUP: Metaprogramming in Julia
COSCUP: Metaprogramming in JuliaCOSCUP: Metaprogramming in Julia
COSCUP: Metaprogramming in Julia
岳華 杜
 
COSCUP: Introduction to Julia
COSCUP: Introduction to JuliaCOSCUP: Introduction to Julia
COSCUP: Introduction to Julia
岳華 杜
 
Introduction to Julia
Introduction to JuliaIntroduction to Julia
Introduction to Julia
岳華 杜
 
20180506 Introduction to machine learning
20180506 Introduction to machine learning20180506 Introduction to machine learning
20180506 Introduction to machine learning
岳華 杜
 
20171127 當julia遇上資料科學
20171127 當julia遇上資料科學20171127 當julia遇上資料科學
20171127 當julia遇上資料科學
岳華 杜
 
20171117 oop and design patterns in julia
20171117 oop and design patterns in julia20171117 oop and design patterns in julia
20171117 oop and design patterns in julia
岳華 杜
 
20171014 tips for manipulating filesystem in julia
20171014 tips for manipulating filesystem in julia20171014 tips for manipulating filesystem in julia
20171014 tips for manipulating filesystem in julia
岳華 杜
 
20170807 julia的簡單而高效資料處理
20170807 julia的簡單而高效資料處理20170807 julia的簡單而高效資料處理
20170807 julia的簡單而高效資料處理
岳華 杜
 
20170715 北Bio meetup
20170715 北Bio meetup20170715 北Bio meetup
20170715 北Bio meetup
岳華 杜
 

More from 岳華 杜 (20)

Julia: The language for future
Julia: The language for futureJulia: The language for future
Julia: The language for future
 
The Language for future-julia
The Language for future-juliaThe Language for future-julia
The Language for future-julia
 
20190907 Julia the language for future
20190907 Julia the language for future20190907 Julia the language for future
20190907 Julia the language for future
 
Metaprogramming in julia
Metaprogramming in juliaMetaprogramming in julia
Metaprogramming in julia
 
Introduction to julia
Introduction to juliaIntroduction to julia
Introduction to julia
 
自然語言處理概覽
自然語言處理概覽自然語言處理概覽
自然語言處理概覽
 
Introduction to machine learning
Introduction to machine learningIntroduction to machine learning
Introduction to machine learning
 
Semantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
Semantic Segmentation - Fully Convolutional Networks for Semantic SegmentationSemantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
Semantic Segmentation - Fully Convolutional Networks for Semantic Segmentation
 
Batch normalization 與他愉快的小伙伴
Batch normalization 與他愉快的小伙伴Batch normalization 與他愉快的小伙伴
Batch normalization 與他愉快的小伙伴
 
從 VAE 走向深度學習新理論
從 VAE 走向深度學習新理論從 VAE 走向深度學習新理論
從 VAE 走向深度學習新理論
 
COSCUP: Foreign Function Call in Julia
COSCUP: Foreign Function Call in JuliaCOSCUP: Foreign Function Call in Julia
COSCUP: Foreign Function Call in Julia
 
COSCUP: Metaprogramming in Julia
COSCUP: Metaprogramming in JuliaCOSCUP: Metaprogramming in Julia
COSCUP: Metaprogramming in Julia
 
COSCUP: Introduction to Julia
COSCUP: Introduction to JuliaCOSCUP: Introduction to Julia
COSCUP: Introduction to Julia
 
Introduction to Julia
Introduction to JuliaIntroduction to Julia
Introduction to Julia
 
20180506 Introduction to machine learning
20180506 Introduction to machine learning20180506 Introduction to machine learning
20180506 Introduction to machine learning
 
20171127 當julia遇上資料科學
20171127 當julia遇上資料科學20171127 當julia遇上資料科學
20171127 當julia遇上資料科學
 
20171117 oop and design patterns in julia
20171117 oop and design patterns in julia20171117 oop and design patterns in julia
20171117 oop and design patterns in julia
 
20171014 tips for manipulating filesystem in julia
20171014 tips for manipulating filesystem in julia20171014 tips for manipulating filesystem in julia
20171014 tips for manipulating filesystem in julia
 
20170807 julia的簡單而高效資料處理
20170807 julia的簡單而高效資料處理20170807 julia的簡單而高效資料處理
20170807 julia的簡單而高效資料處理
 
20170715 北Bio meetup
20170715 北Bio meetup20170715 北Bio meetup
20170715 北Bio meetup
 

Recently uploaded

May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
Globus
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
rickgrimesss22
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
Tendenci - The Open Source AMS (Association Management Software)
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 

Recently uploaded (20)

May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
SOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBrokerSOCRadar Research Team: Latest Activities of IntelBroker
SOCRadar Research Team: Latest Activities of IntelBroker
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Understanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSageUnderstanding Globus Data Transfers with NetSage
Understanding Globus Data Transfers with NetSage
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptxTop Features to Include in Your Winzo Clone App for Business Growth (4).pptx
Top Features to Include in Your Winzo Clone App for Business Growth (4).pptx
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Corporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMSCorporate Management | Session 3 of 3 | Tendenci AMS
Corporate Management | Session 3 of 3 | Tendenci AMS
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 

[COSCUP 2023] 我的Julia軟體架構演進之旅

  • 1. 我的 Julia 軟體架構演進之旅 Yueh-Hua Tu Ph.D. ML Engineer@Taiwan AI Labs Saturday 29th July, 2023 Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 1 / 28
  • 2. Projects Open source projects FluxML/GeometricFlux.jl yuehhua/GraphSignals.jl yuehhua/CDGRNs.jl JuliaSingleCellOmics/SnowyOwl.jl Current work Federated learning system architecture Bioinformatics analysis tool development (e.g. GWAS, linkage disequilibrium and statistics) Program optimization for execution performance Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 2 / 28
  • 3. Outline 1. Prototyping-Development Iteration 2. TDD and Test Coverage 3. Evolutionary Design 4. Principles of Software Engineering 5. Development Mindset Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 3 / 28
  • 4. Developing from scratch If we want a project for statistical analysis, where could we start? Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 4 / 28
  • 5. Prototyping linear regression Inference y = Xβ 1 julia> predict(X, β)=X∗β Fitting β = (XT X)−1 XT y 1 julia> fit(X, y) = inv(X'*X) * X'*y Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 5 / 28
  • 6. Prototyping-Development Iteration Prototyping-Development Iteration Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 6 / 28
  • 7. Prototyping-Development Iteration Prototyping-Development Iteration (PDI) Prototyping first then develop for flexibility and performance! For prototyping and researching Figure: Scripts ⇒ For development Figure: Codebase Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 7 / 28
  • 8. Prototyping-Development Iteration Prototyping Figure: Scripts Implement a simple and standalone feature in a script to ensure correctness. 1 julia> predict(X, β)=X∗β 2 3 julia> fit(X, y) = inv(X'*X) * X'*y And try to wrap these features into functions. Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 8 / 28
  • 9. Prototyping-Development Iteration Development Figure: Codebase Puts functions or components into your codebase and design for reusablility and flexibility. 1 struct LinearRegressionModel 2 β 3 end 4 5 coefs(m::LinearRegressionModel) = m.β 6 7 predict(m::LinearRegressionModel, X) = X*coefs(m) 8 9 fit(::Type{LinearRegressionModel}, X, y) = LinearRegressionModel(inv(X'*X) * X'*y) , → After putting components into codebase, ensure your scripts still work for you. Don't put to much specifics into codebase (e.g. data, configs). Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 9 / 28
  • 10. TDD and Test Coverage TDD and Test Coverage Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 10 / 28
  • 11. TDD and Test Coverage Test-Driven Development (TDD) Actually, PDI is a kind of TDD process. We still need to add some test cases and ensure tests are passed. Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 11 / 28
  • 12. TDD and Test Coverage TDD in Julia TDD is very simple in Julia. test/runtests.jl 1 @testset "MyProject.jl" begin 2 @test coefs(model) == β 3 ... 4 end 1 (@v1.9) pkg> test Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 12 / 28
  • 13. TDD and Test Coverage Develop for flexibility src/stats.jl 1 cov(X, Y) = innerprod(X, Y) src/linalg.jl 1 innerprod(x, y) = x'*y src/regression.jl fit(::Type{LinearRegressionModel}, X, y) = LinearRegressionModel(inv(innerprod(X, X)) * innerprod(X, y)) , → Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 13 / 28
  • 14. TDD and Test Coverage Develop for performance src/linalg.jl function innerprod(X::AbstractMatrix, y::AbstractVector) # acceleration techniques: SIMD, GPU... end function innerprod(X::AbstractMatrix, Y::AbstractMatrix) # acceleration techniques: SIMD, GPU... end Specification for optimization and keep consistent interfaces. Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 14 / 28
  • 15. TDD and Test Coverage Test coverage Keep high test coverage as possible to ensure your codebase provides desired features. Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 15 / 28
  • 16. Evolutionary Design Evolutionary Design Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 16 / 28
  • 17. Evolutionary Design Adding new features If we want to add new approach to solve a linear system, how can we do? Ax = b 1 using LinearSolve 2 3 A = rand(4, 4) 4 b = rand(4) 5 prob = LinearProblem(A, b) 6 sol = solve(prob) Adding new features could be prototyped by Adding types Extending existing functions Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 17 / 28
  • 18. Evolutionary Design Adding types Original struct RegularSolver end solve(m::RegularSolver, A, b) = solve(LinearProblem(A, b)) , → ⇒ Adding CholeskySolver 1 abstract type LinearSolver end 2 3 struct RegularSolver <: LinearSolver end 4 struct CholeskySolver <: LinearSolver end 5 6 solve(m::RegularSolver, A, b) = solve(LinearProblem(A, b)) , → Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 18 / 28
  • 19. Evolutionary Design Extending functions/methods Original abstract type LinearSolver end struct RegularSolver <: LinearSolver end , → struct CholeskySolver <: LinearSolver end , → solve(m::RegularSolver, A, b) = solve(LinearProblem(A, b)) , → ⇒ Extending solve to CholeskySolver. 1 abstract type LinearSolver end 2 3 struct RegularSolver <: LinearSolver end 4 struct CholeskySolver <: LinearSolver end 5 6 solve(m::RegularSolver, A, b) = solve(LinearProblem(A, b)) , → 7 solve(m::CholeskySolver, A, b) = # Cholesky decomposition... , → Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 19 / 28
  • 20. Principles of Software Engineering Principles of Software Engineering Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 20 / 28
  • 21. Principles of Software Engineering Single Responsibility Principle A class or function should be responsible to only one actor. LinearModel: represent a linear model coefs: returns model coefficients fit: fitting model LinearSolver: approach to solve a linear system solve: determines how to solve a linear system Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 21 / 28
  • 22. Principles of Software Engineering Open-Closed Principle A module will be said to be open for extension and be said to be closed for modification. struct LinearRegressionModel β end coefs(m::LinearRegressionModel) = m.β ⇒ 1 abstract type LinearModel end 2 3 struct LinearRegressionModel <: LinearModel , → 4 β 5 end 6 7 struct LogisticRegressionModel <: LinearModel , → 8 β 9 end 10 11 coefs(m::LinearRegressionModel) = m.β 12 coefs(m::LogisticRegressionModel) = m.β Benefitial from Julia's features of type and method separation, it's easy to add new types or Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 22 / 28
  • 23. Principles of Software Engineering Liskov Substitution Principle Derived class can be able to replace its base class. abstract type LinearModel end struct LinearRegressionModel <: LinearModel β end struct LogisticRegressionModel <: LinearModel β end Since Julia's subtyping system doesn't allow composite types as super types, Julia always run composite types in practice. Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 23 / 28
  • 24. Principles of Software Engineering Interface Segregation Principle No code should be forced to depend on methods it does not use. 1 julia> model = fit(LinearRegressionModel, X, y) , → 2 3 julia> coefs(model) 4 5 julia> model = fit(LogisticRegressionModel, X, y) , → 6 7 julia> coefs(model) User just need to know interfaces. 1 module MyPackage 2 abstract type LinearModel end 3 struct LinearRegressionModel <: LinearModel , → 4 β 5 end 6 struct LogisticRegressionModel <: LinearModel , → 7 β 8 end 9 coefs(m::LinearRegressionModel) = m.β 10 coefs(m::LogisticRegressionModel) = m.β 11 end Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 24 / 28
  • 25. Principles of Software Engineering Dependency Inversion Principle Dependency injection 1 abstract type LinearSolver end 2 3 struct RegularSolver <: LinearSolver end 4 struct CholeskySolver <: LinearSolver end 5 struct QRSolver <: LinearSolver end 1 abstract type LinearModel end 2 3 struct LinearRegressionModel <: LinearModel end , → 4 struct LogisticRegressionModel <: LinearModel end , → 5 6 fit(::Type{LinearRegressionModel}, X, y; algo=CholeskySolver()) , → 7 fit(::Type{LogisticRegressionModel}, X, y; algo=CholeskySolver()) , → Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 25 / 28
  • 26. Development Mindset Development Mindset Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 26 / 28
  • 27. Development Mindset Issues and Pull Requests 貢獻者 遇到善於給建議(機車)的人 如何主持跟維護專案 Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 27 / 28
  • 28. Development Mindset Thank you for attention Y.H. Tu (Taiwan AI Labs) Evolutional Software Architecture Saturday 29th July, 2023 28 / 28